/*
 * Student Name: Philippe Gambling
 * Course: CSCI 5733
 * Assignment: Homework 1
 * Created: Jun 18, 2009
 * Modified: Jun 18, 2009
 * 
 * Class Name: NewsSourceUrl
 * Description: Creates a Reader interface from a given URL.
 */

package csci5733.hw1;

import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.net.URLConnection;

/**
 *
 * @author Philippe Gambling
 */
public class NewsUrl {
    private final String url;

    public NewsUrl(String url) {
        this.url = url;
    }

    public Reader query(String topic) throws Exception {
        // Connect to the URL
        URL u=new URL(this.url+topic);
        URLConnection UC=u.openConnection();
        UC.setRequestProperty ( "User-agent", "dcm.uhcl.edu/c5733su09gamblingp/hw/h1");
        return new InputStreamReader(UC.getInputStream());
    }
}
